package com.hxut.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
import java.io.IOException;
import java.io.PrintWriter;

@WebFilter(filterName = "MyFilter01",urlPatterns = "/testServlet01")
public class MyFilter01 implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        PrintWriter out = servletResponse.getWriter();
        out.println("filter01   Before");
        filterChain.doFilter(servletRequest, servletResponse);
        out.println("filter01   After");
    }

    @Override
    public void destroy() {
        System.out.println("MyFilter destroy()");
    }
}
